package com.biom3d.dashboard;

import com.biom3d.R;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class ContactActivity extends Activity {

	Button buttonSend;
	EditText textTo;
	EditText textSubject;
	EditText textMessage;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.help_contact_layout);
		
		DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        if(dm.widthPixels < 600) {
        	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }

		buttonSend = (Button) findViewById(R.id.btn_send);
		textSubject = (EditText) findViewById(R.id.EditTextSubject);
		textMessage = (EditText) findViewById(R.id.EditTextMessage);

		buttonSend.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				String to = "petsi-ufu@googlegroups.com";
				String subject = textSubject.getText().toString();
				String message = textMessage.getText().toString();

				if (textSubject.getText().toString().length() == 0) {
					textSubject.setError("Enter Subject");
				} else if (textMessage.getText().toString().length() == 0) {
					textMessage.setError("Enter Message");
				} else {
					Intent email = new Intent(Intent.ACTION_SEND);
					email.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
					// email.putExtra(Intent.EXTRA_CC, new String[]{ to});
					// email.putExtra(Intent.EXTRA_BCC, new String[]{to});
					email.putExtra(Intent.EXTRA_SUBJECT, subject);
					email.putExtra(Intent.EXTRA_TEXT, message);

					// need this to prompts email client only
					email.setType("message/rfc822");

					startActivity(Intent.createChooser(email,
							"Choose an Email client:"));
				}
			}
		});
	}
}
